package com.example.cushion.realize.setting;

import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.example.cushion.base.BaseCommonActivity;

import org.itzheng.and.baseutils.log.LogHelper;
import org.itzheng.and.ble.bean.BluetoothDeviceInfo;
import org.itzheng.and.ble.callback.BleScanCallback;
import org.itzheng.and.ble.utils.BleScanUtils;

import java.util.List;

/**
 * Title:<br>
 * Description: <br>
 *
 * @email ItZheng@ZoHo.com
 * Created by itzheng on 2018-3-14.
 */
public class BleScanActivity extends BaseCommonActivity {
    private static final String TAG = "BleScanActivity";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle("蓝牙搜索");
        init();
    }

    BleScanUtils bleScanUtils = BleScanUtils.newInstance().setFilter(null);

    private void init() {
        bleScanUtils.startLeScan(new BleScanCallback() {
            @Override
            public void onLeScan(List<BluetoothDeviceInfo> list) {
                LogHelper.d(TAG, "" + list.size());
            }

            @Override
            public void onLeScan(BluetoothDevice bluetoothDevice, int i, byte[] bytes) {
                LogHelper.d(TAG, "Device:" + bluetoothDevice.getName() + ":" + bluetoothDevice.getAddress());
            }
        });
    }
}
